<?php require_once("header.php");?>
	<div id="content">
		<div id="content-title">
			Welcome to Pobunesia!
		</div>
           <div id="best-content"> 
            <h3>Best Content</h3>
				<?php
					if (!isset($_SESSION['login_username'])) {
						$disabled = "disabled=true";
					}
					else {
						$disabled = "disabled=true";
					}
					
					$con = mysql_connect("localhost","progin","progin");
				
					if (!$con) {
						die('Could not connect: ' . mysql_error());
					}

					mysql_select_db("progin_171_13509045", $con) or die("Cannot find database");
					
					$sql = "SELECT * FROM konten ORDER BY jumlahlike DESC LIMIT 0, 3";
					$result = mysql_query($sql);
					$increment = 1;
					
					while ($row = mysql_fetch_array($result)) {
						$labelid = "likecount" + $increment;
						$contentID = $row['id_konten'];
						$like = $row['jumlahlike'];
						echo "<h3><a href=\"content.php?contentid=".$row['id_konten']."\" style=\"text-decoration:none;\">";
						echo $row['judul'];
						print '</a></h3>
								<img border="0" src="'.$row['url'].'" alt="Pulpit rock" width="304" height="228" />
								<br/>
								<div id="likedislike">';						
						echo "<input type='button' id='likebutton' value='like' onclick=\"changeLike('$contentID', '$like', '$labelid', 'up');\" $disabled></input>
								<input type='button' id='dislikebutton' value='dislike' onclick=\"changeLike('$contentID', '$like', '$labelid', 'down');\" $disabled></input>
								<label id='$labelid'>";
						echo $row['jumlahlike'];
						print ' likes</label>
								</div>';
						$increment = $increment + 1;
					}
				?>
            </div>
           
            <div id="most-commented">
            	<h3>Most Commented</h3>
					<?php
						$sql =  "SELECT * FROM konten ORDER BY jumlahkomentar DESC LIMIT 0, 3";
						$result = mysql_query($sql);
						$increment = 4;
					
						while ($row = mysql_fetch_array($result)) {
							$labelid = "likecount" + $increment;
							$contentID = $row['id_konten'];
							$like = $row['jumlahlike'];
							echo "<h3><a href=\"content.php?contentid=".$row['id_konten']."\" style=\"text-decoration:none;\">";
							echo $row['judul'];
							print '</a></h3>
									<img border="0" src="'.$row['url'].'" alt="Pulpit rock" width="304" height="228" />
									<br/>
									<div id="likedislike">';						
							echo "<input type='button' id='likebutton' value='like' onclick=\"changeLike('$contentID', '$like', '$labelid', 'up');\" $disabled></input>
									<input type='button' id='dislikebutton' value='dislike' onclick=\"changeLike('$contentID', '$like', '$labelid', 'down');\" $disabled></input>
									<label id='$labelid'>";
							echo $row['jumlahlike'];
							print ' likes</label>
									</div>';
							$increment = $increment + 1;
						}
					?>
			</div>
	</div>
<?php require_once("footer.php");?>
